<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of seminar
 *
 * @author jan
 */
class seminarHelper {
    //put your code here

    public static function dayCount($seminar) {
        return date::diffDates($seminar['begin_date'], $seminar['end_date']) + 1;
    }
    
    /**
     * Prints a list of seminars used in organization part. Seminars must contain necessery fields.
     */
    public static function printSeminarListForOrganization($seminarList) {
        if (count($seminarList) > 0) {
            echo '<ul class="orgSeminarList">';
            for ($i = 0; $i < count($seminarList); $i++) {
                $seminar = $seminarList[$i];
                echo '<li>';
                if ($i == 0) {
                    echo '<span class="currentSeminar">';
                }
                echo html::anchor('org/orgSeminar/display?id=' . $seminar['id'], $seminar['name']);
                echo ' <span class="description">[' . format::dateInterval($seminar['begin_date'], $seminar['end_date']) . ']</span>';
                if ($i == 0) {
                    echo '</span>';
                }

                $paymentAcceptance = $seminar['paymentAcceptance'];
                echo '<ul>';
                echo '<li>' . html::anchor('/org/orgSeminar/registrationList?id=' . $seminar['id'], text::get('orgSeminar-registrationList')) . ': ' . text::get('orgSeminar-registrationCount', $seminar['registrationCount']);
                if ($seminar['unconfirmedRegistrationCount']) {
                	echo '<br/><p class="warningNote">' . text::getEscaped('orgSeminar-includingUnconfirmed', $seminar['unconfirmedRegistrationCount']) . '</p>';
                }
                echo '</li>';
                
                $sessionData = SessionData::instance();
                $organization = $sessionData->getAuthOrg();
                if ($organization['id'] != Kohana::config('yosemin.onArrivalPaymentOrganizationId')) {
                    echo '<li>' . html::anchor('/org/paymentAcceptance/edit?id=' . $seminar['id'], text::get('orgSeminar-paymentAcceptance')) . '</li>';
                
                    if ($paymentAcceptance['accepts_cash'] || $paymentAcceptance['accepts_bank_transfer']) {
                        echo '<ul>';
                        echo '<li>' . text::getEscaped('paymentAcceptance-deadline') . ': ' . format::date($paymentAcceptance['deadline']) . '</li>';
                        echo '<li>' . text::getEscaped('paymentAcceptance-inCash') . ': ' . format::boolean($paymentAcceptance['accepts_cash']) . '</li>';
                        echo '<li>' . text::getEscaped('paymentAcceptance-inBank') . ': ' . format::boolean($paymentAcceptance['accepts_bank_transfer']) . '</li>';
                        echo '</ul>';
                    }
                }

                echo '</ul>';
                echo '</li>';
            }
            echo '</ul>';
        }
    }
    
    public static function arePapersRequired($birthDate) {
    	$age = date::personAge($birthDate);
    	return $age >= constants::$requireIdCardFromAge;
    }
}
